package com.qianyu.project.service.handler;

import com.alibaba.fastjson.JSON;
import com.qianyu.project.core.annotation.FlowHandler;
import com.qianyu.project.core.bean.FormAudit;
import com.qianyu.project.core.context.handler.FlowFinishedHandler;
import com.qianyu.project.entity.LaborContract;
import com.qianyu.project.mapper.provider.smj.smjLaberControllerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@FlowHandler("labor_contract")
public class LaborContractHandler implements FlowFinishedHandler {
    @Autowired
    private smjLaberControllerDao ld;

    @Override
    public void postAllowHandle(String jsonForm, FormAudit formAudit) {
        this.commonUpdate(jsonForm, formAudit , 3);
    }

    @Override
    public void postRefuseHandle(String jsonForm, FormAudit formAudit) {
        this.commonUpdate(jsonForm, formAudit , 2);
    }



    private void commonUpdate(String jsonForm,FormAudit formAudit, Integer approveStatus) {
        LaborContract laborContract = JSON.parseObject(jsonForm,LaborContract.class);
        ld.UpdateApproveStatus(approveStatus,laborContract.getId());
    }
}
